<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8"/>
    <title>动效图片</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <link rel="stylesheet" th:href="@{/css/font.css}"/>
    <link rel="stylesheet" th:href="@{/css/xadmin.css}"/>
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a><cite>模板列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form id="form" class="layui-form layui-col-space5" th:action="'/wx/mini/admin/photo/list/'+${wxMiniAppId}">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="enable">
                                <option th:if="${enable==null || enable==99}" value="99" selected>请选择状态</option>
                                <option th:if="${enable!=null && enable!=99}" value="99">请选择状态</option>
                                <option th:if="${enable!=null && enable==1}" value="1" selected>启用</option>
                                <option th:if="${enable==null || enable==99 || enable==0}" value="1">启用</option>
                                <option th:if="${enable!=null && enable==0}" value="0" selected>停用</option>
                                <option th:if="${enable==null || enable==99 || enable==1}" value="0">停用</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon"></i></button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="xadmin.open('添加','')"><i class="layui-icon"></i>添加</button>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th style="display: none;">小程序id</th>
                            <th>模板编号</th>
                            <th>模板名称</th>
                            <th>动效类型</th>
                            <th>是否启用</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="item,itemStat : ${list}">
                            <td style="display: none;" th:text="${item.wxMiniAppId}"></td>
                            <td th:text="${item.no}"></td>
                            <td th:text="${item.name}"></td>
                            <td th:if="${item.moveType.equals('DYNAMIC_ONE')}">动效一</td>
                            <td th:if="${item.moveType.equals('DYNAMIC_TWO')}">动效二</td>
                            <td th:if="${item.enable==1}"><input type="checkbox" th:value="${item.wxMiniAppId+'_'+item.no}" lay-filter="switchID" name="switch"  lay-text="启用|停用" lay-skin="switch" checked="checked"></td>
                            <td th:if="${item.enable==0}"><input type="checkbox" th:value="${item.wxMiniAppId+'_'+item.no}" lay-filter="switchID" name="switch"  lay-text="启用|停用" lay-skin="switch"></td>
                            <td class="td-manage">
                                <button class="layui-btn layui-btn-danger layui-btn-xs"  th:onclick="'xadmin.open(\'删除\',\'\')'" >删除</button>
                                <button class="layui-btn layui-btn layui-btn-xs"  th:onclick="'xadmin.open(\'编辑\',\'\')'" >编辑</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>layui.use(['laydate', 'form'],
    function() {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    //图片预览
    function yulan(url) {
        layer.alert("<img src='"+url+"'/>");
    }

    function qiyong(id) {
        $.post("/wx/admin/photo/enable/"+id+"/1",function(data,status){
            location.reload();
        });
    }

    function tingyong(id) {
        $.post("/wx/admin/photo/enable/"+id+"/0",function(data,status){
            location.reload();
        });
    }

    function checkfile() {
        if($("#file").val()==null||$("#file").val()==''){
            layer.alert("请选择要上传的图片！");
            return false;
        }
        return true;
    }

    function deleteById(id) {
        layer.confirm("确定删除此记录？",{btn: ['确定', '取消'], title: "提示"},function () {
            $.post("/wx/admin/photo/delete/"+id,function(data,status){
                location.reload();
            });
        });
    }

    layui.use(['form'], function(){
        var form = layui.form;
        form.on('switch(switchID)', function(data){
            var value = data.elem.value;
            var arrays = value.split("_");
            if(this.checked){
                $.post("/wx/mini/admin/photo/enable/"+arrays[0]+"/"+arrays[1]+"/1", function(data,status){
                    layer.msg('已启用!',{icon:1,time:1000});
                });
            }else{
                $.post("/wx/mini/admin/photo/enable/"+arrays[0]+"/"+arrays[1]+"/0", function(data,status){
                    layer.msg('已停用!',{icon:1,time:1000});
                });
            }
        });
    });
</script>

</html>